
<!--top结束-->
<script type="text/javascript" src="<?= base_url() ?>resource/js/layer/layer.js"></script>
<div class="mian">
    <div class="mian1">
        <div class="mian2">
            <!--left start-->
            <?php $this->load->view('defaults/common/left'); ?>
            <!--left end-->
            <!--right start-->
            <div class="right">
                <!--breadcrumb start-->
                <div class="righta"><?= $this->breadcrumb->generateHTML(); ?> </div>
                <!--breadcrumb end-->
                <!-- contents start -->
                <div id="contents">
                    <div id="contents_container">
                        <form id='out_stock_form' action="<?= blang_url('wms/InStock/abnormal_stock') ?>" method="post" name="myform" onsubmit="return myform_submit()" autocomplete="off" >
                            <table cellpadding="0" cellspacing="0" id="table_forms" border="1">
                                <tr>
                                    <td class="forms_left"><?= lang('wms_ckdm') ?>:</td>
                                    <td>                                        <select id="whs_code"  name="whs_code"  placeholder="whs_code" disabled>
                                            <option value =""></option>  
                                           <?php foreach($whsCode as $oneWhs){?>
                                                  <option value ="<?=$oneWhs['whs_code']?>"><?='('.$oneWhs['whs_code'].')'.$oneWhs['whs_name']?></option>  
                                                                        <?php }?>
                                        </select></td>
                                </tr>
                                <tr>
                                    <td class="forms_left"><?= lang('wms_panel_30001') ?>:</td>
                                    <td>
                                        <select  id="in_out_type" name="in_out_type"  placeholder="in_out_type" disabled>
                                            <option value =""></option>  
                                            <?php foreach ($in_out_type as $type)
                                            { ?>
                                                <option value ="<?= $type['key'] ?>"><?= $type['name_cn'] ?></option>  
<?php } ?>
                                        </select></td>
                                </tr>
                                <tr>
                                    <td class="forms_left">PID:</td>
                                    <td><input id="pid" type="text" name="pid" value="" />-</td>
                                </tr>
                                <tr>
                                    <td class="forms_left">SKU:</td>
                                    <td><input id="sku" type="text" name="sku" value="" />-</td>
                                </tr>
                                <tr>
                                    <td class="forms_left"><?= lang('product_wlsl') ?>:</td>
                                    <td><input id="quantity" type="number" name="quantity" value="" readOnly="true"  min="1" max="10" /></td>
                                </tr>
                                <tr>
                                    <td class="forms_left"><?= lang('wms_panel_30010') ?>:</td>
                                    <td><input id="ask_staff" type="text" name="ask_staff" value="" /></td>
                                </tr>
                                <tr>
                                    <td class="forms_left"><?= lang('wms_panel_30011') ?>:</td>
                                    <td><input id="ref_num" type="text" name="ref_num" value=""  readOnly="true"/>*</td>
                                </tr>
                                <tr>
                                    <td class="forms_left"><?= lang('wms_panel_30002') ?>:</td>
                                    <td><textarea rows="2" cols="50" id="comments" name="comments" value=""></textarea></td>
                                </tr>
                                <tr>
                                    <td align="center" colspan="2" class="sub_padding_right">
                                        <button id="_button" type="button" onclick="stock_out()"  style="margin-right: 20px;width: 150px; height: 30px; margin-left: 200px;" ><?= lang('wms_panel_30012') ?></button>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="forms_left"  colspan="2"  id="msg"></td>
                                </tr>
                            </table>
                        </form>
                    </div>
                </div>
                <div id="contents">
                    <div id="ct_search" >
                        <form action="<?=blang_url('orders/MyOrder/'.$post_type)?>" method="post" name="searchform" >
                            <table id="search_tb">
                                <tr>
                                    <td>
                                        &nbsp;
                                        keyword：<input size="32" name="keyword" value="<?=$keyword?>" placeholder="orderNum/productSku/imei/" />
                                        &nbsp;&nbsp;&nbsp;
                                        <select name="service_center">
                                            <option value="" >--service center--</option>
                                            <?php foreach ($serviceCenterList as $rs):?>
                                                <option value="<?=$rs['id']?>" <?=$optServiceCenter[$rs['id']]?> > <?=$rs['name_'.$curLang]?> </option>
                                            <?php endforeach;?>
                                        </select>
                                        <?php if($post_type=='stayRepair'):?>
                                        &nbsp;&nbsp;&nbsp;
                                        <select name="status_id" >
                                            <option value="" >--status--</option>
                                            <?php foreach ($statusList as $rs):?>
                                                <option value="<?=$rs['id']?>" <?=$optStatus[$rs['id']]?> > <?=$rs['name_'.$curLang]?> </option>
                                            <?php endforeach;?>
                                        </select>
                                        <?php endif;?>
                                        &nbsp;&nbsp;&nbsp;
                                        <input type="submit" name="searchSubmit" value="<?=lang('public_cx')?> " />
                                        <a href="<?=$outputUrl?>" style="margin-left: 50px;"><?=lang('public_dcsj')?></a>
                                        <span style="margin-left: 100px;">Total:<?=$total_rows?></span>
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>
                    <div class="ct_content" >
                        <table class="tbwd800" cellspacing="0">
                            <thead class="table_thead" >
                            <tr>
                                <th width="15%" ><?=lang('order_wxdh')?></th>
                                <th width="10%" ><?=lang('order_lydh')?></th>
                                <th width="5%" >type</th>
                                <th width="5%" >category</th>
                                <th width="10%" ><?=lang('order_zt')?></th>
                                <th width="5%" >sku</th>
                                <th width="10%" >imei</th>
                                <th width="5%" ><?=lang('order_clr')?></th>
                                <th width="10%" ><?=lang('order_rq')?></th>
                                <th width="10%" ><?=lang('order_cl')?></th>
                                <th width="15%" ><?=lang('order_cz')?></th>
                            </tr>
                            </thead>
                            <?php if($show_pages):?>
                                <tfoot id="tfootPage">
                                <tr>

                                    <td colspan="11" ><?=$show_pages?></td>
                                </tr>
                                </tfoot>
                            <?php endif;?>
                            <tbody>
                            <?php if($dataList): foreach ($dataList as $key=>$rs):?>
                                <tr class="moves" <?=$rs['timeout']?>>
                                    <td width="15%" style="text-align: center;">
                                        <a href="<?=blang_url('orders/Order_new/inDetails/'.$rs['oid'])?>" style="color: <?=$rs['holdColorOrder']?>">
                                            <span style="color: <?=$rs['overtime_status']?'#ff0000':''?>"><?=$rs['order_num']?></span>
                                        </a>
                                        <a href="<?=blang_url('orders/Order_new/edit/'.$rs['oid'])?>" >edit</a>
                                    </td>
                                    <td width="10%"><?=$rs['source_oid']?></td>
                                    <td width="5%"><?=$rs['serviceName']?></td>
                                    <td width="5%"><?=$rs['categoryName']?></td>
                                    <td width="10%"><?=$rs['statusName']?></td>
                                    <td width="5%" ><?=$rs['productSku']?></td>
                                    <td width="10%" ><?=$rs['imei']?></td>
                                    <td width="5%" ><?=$rs['add_user']?></td>
                                    <td width="10%" title="<?=$rs['add_time']?>"><?=$rs['create_time']?></td>
                                    <td width="10%" >
                                        <?php if($rs['orderAvailable']==2 || $rs['available']==2): ?>
                                            <span style="color: darkred;">HOLD</span>
                                        <?php else: ?>
                                            <?php if($rs['status_id']==14 && $rs['isInTrackNum']): ?>
                                                <a href="javascript:;" onclick="shipped('<?=$rs['id']?>','<?=$rs['oid']?>')">
                                                    <?=$rs['nextAct']['name']?>
                                                </a>
                                            <?php else: ?>
                                                <a href="<?=blang_url($rs['nextAct']['url'])?>" >
                                                    <?=$rs['nextAct']['name']?>
                                                </a>
                                            <?php endif;?>
                                        <?php endif;?>
                                    </td>
                                    <td width="15%" align="center">
                                        <a href="<?=blang_url('products/Product_new/inDetails/'.$rs['id'])?>" style="color: <?=$rs['holdColorProduct']?>">Detail</a>
                                        <?php if(!$rs['isSync_sf'] && $role=='admin'): ?>
                                            <a href="<?=blang_url('orders/Order_new/pushSF/'.$rs['oid'])?>" >SF</a>
                                        <?php endif;?>
                                        <a href="<?=blang_url('products/Product_new/edit/'.$rs['id'])?>" >edit</a>
                                    </td>
                                </tr>
                            <?php endforeach; else:?>
                                <tr><th colspan="11" height="40"><?=lang('public_mygdsj')?>....</th></tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
                <!-- contents end -->
            </div>
            <!--right end-->
            <div class="clear"></div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(window).load(function() {
        $("#pid").focus();
    }); 
    $('#pid').bind('keypress', function (event) {
        if (event.keyCode == "13") {
            $("#sku").focus();
        }
    });
    $('#quantity').bind('keypress', function (event) {
        if (event.keyCode == "13") {
            $("#ask_staff").focus();
        }
    });
    $('#sku').bind('keypress', function (event) {

        if (event.keyCode == "13") {
            if(true){
                //enter 获取配件信息
                var LDindex;
                var sku= $("#sku").val();
                var pid= $("#pid").val();
                $.ajax({
                    type:'post',
                    timeout:60000,
                    data: {"pid":pid,"sku":sku},
                    url:"<?= blang_url('wms/InStock/get_product_part') ?>",
                    beforeSend:function(XMLHttpRequest){
                        LDindex = layer.load(1, {
                            shade: [0.1,'#fff'] //0.1透明度的白色背景
                        })
                    }, 
                    success: function (rs) {
                        layer.close(LDindex); 
                        obj=JSON.parse(rs);
                        if(true==obj.success){
                            $('#quantity').val(obj.data.quantity);
                            $('#ask_staff').val(obj.data.technician);
                            $('#ref_num').val(obj.data.order_num);
                            $('#whs_code').val(obj.data.whs_code);
                            $('#in_out_type').val(obj.data.type);
                            $("#_button").focus();
                        }
                        else{
                            alert(obj.msg);
                            $('#sku').val("");
                            $('#pid').val("");
                            $('#quantity').val("");
                            $('#ask_staff').val("");
                            $('#ref_num').val("");
                            $('#ask_staff').val("");
                            $("#pid").focus();
                        }
                    },
                    error: function (e, jqxhr, settings, exception) {

                    },
                    complete : function(XMLHttpRequest,status){
                        layer.close(LDindex); 
                        if(status=='timeout'){
                            alert("Request timed out,Please try again!");
                        }
                    }
                });
            }else{
                $("#quantity").focus();
            }
        }
    });
    
    function stock_out(){
        //loading层
        var LDindex;
        var whs_code= $("#whs_code").val();
        var in_out_type= $("#in_out_type").val();
        var dataParam = $("#out_stock_form").serializeArray();
        dataParam.push({"name":"whs_code","value":whs_code});
        dataParam.push({"name":"in_out_type","value":in_out_type});
        $.ajax({
            type:'post',
            timeout:60000,
            data: dataParam,
            url:"<?= blang_url('wms/InStock/m_out') ?>",
            beforeSend:function(XMLHttpRequest){
                LDindex = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                })
            }, 
            success: function (rs) {
                layer.close(LDindex); 
                obj=JSON.parse(rs);
                if(true==obj.success){
                    var pid= $("#pid").val("");
                    var sku= $("#sku").val("");
                    var whs_code= $("#whs_code").val("");
                    var in_out_type= $("#in_out_type").val("");
                    var quantity= $("#quantity").val("");
                    var ask_staff= $("#ask_staff").val("");
                    var ref_num= $("#ref_num").val("");
                    var comments= $("#comments").val("");
                    $("#pid").focus();
                    $("#msg").html('Success!'+obj.msg);
                }
                else{
                    alert(obj.msg);
                    $("#sku").focus();
                }
            },
            error: function (e, jqxhr, settings, exception) {

            },
            complete : function(XMLHttpRequest,status){
                layer.close(LDindex); 
                if(status=='timeout'){
                    alert("Request timed out,Please try again!");
                }
            }
        });
    }
</script>
